home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0048_Another Long filename unit.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  1016 b   |  42 lines

  1. unit LFN_ALT;
  2.  
  3. interface
  4.  
  5. // This unit provides two functions that conver
  6. // filenames from the long format to the 8.3
  7. // format, and from the 8.3 format to the long
  8. // format.
  9.  
  10. function AlternateToLFN(alternateName: String): String;
  11. function LFNToAlternate(LongName: String): String;
  12.  
  13. implementation
  14.  
  15. uses Windows;
  16.  
  17. function AlternateToLFN(alternateName: String): String;
  18. var temp: TWIN32FindData;
  19.     searchHandle: THandle;
  20. begin
  21.   searchHandle := FindFirstFile(PChar(alternateName), temp);
  22.   if searchHandle <> ERROR_INVALID_HANDLE then
  23.     result := String(temp.cFileName)
  24.   else
  25.     result := '';
  26.   Windows.FindClose(searchHandle);
  27. end;
  28.  
  29. function LFNToAlternate(LongName: String): String;
  30. var temp: TWIN32FindData;
  31.     searchHandle: THandle;
  32. begin
  33.   searchHandle := FindFirstFile(PChar(LongName), temp);
  34.   if searchHandle <> ERROR_INVALID_HANDLE then
  35.     result := String(temp.cALternateFileName)
  36.   else
  37.     result := '';
  38.   Windows.FindClose(searchHandle);
  39. end;
  40.  
  41. end.
  42.